﻿using System.Collections.Generic;
using MongoDB.Driver;
using System;

namespace FingerTip.Infrastructure.MongoDb
{
    public class MongoDbClient:Singleton<MongoDbClient>
    {
        private readonly MongoClient _client;
        public MongoDbClient()
        {
            var set = new MongoClientSettings();
            var address = new List<MongoServerAddress>();
            var lstCredential = new List<MongoCredential>();
            
            var connString = MongoDbConfig.Instance.ConnectionString;
            if (string.IsNullOrEmpty(connString))
            {
                connString = "mongodb://localhost";
            }
            _client = new MongoClient(connString);
        }

        public IMongoDatabase GetDatabase(string database)
        {
            if (string.IsNullOrEmpty(database))
                throw new ArgumentNullException(nameof(database));
            return _client.GetDatabase(database);
        }
    }
}